home *** CD-ROM | disk | FTP | other *** search
- /************************************************************************/
- /* rooma.c */
- /* room code for Citadel bulletin board system */
- /************************************************************************/
-
- /************************************************************************/
- /* history */
- /* */
- /* SEE THE INCREM.* FILES FOR FURTHER HISTORICAL NOTES */
- /* 84Jul12 JLS & HAW gotoRoom() and dumpRoom() modified for <S>kip. */
- /* 84Apr04 HAW Start 1.50a update */
- /* 83Feb24 Insert check for insufficient RAM, externs too low. */
- /* 82Dec06 CrT 2.00 release. */
- /* 82Nov05 CrT main() splits off to become citadel.c */
- /************************************************************************/
-
- #include "ctdl.h"
-
- /************************************************************************/
- /* Contents */
- /* */
- /* dumpRoom() tells us # new messages etc */
- /* fDir() prints out a filename for a dir listing */
- /* fillMailRoom() set up Mail> from log record */
- /* gotoRoom() handles "g(oto)" command for menu */
- /* initCitadel() system startup initialization */
- /* listRooms() lists known rooms */
- /* openFile() opens a .sys file */
- /* retRoom() handle Ungoto command */
- /* roomExists() returns slot# of named room else ERROR */
- /* searchRooms() searches room list for matching string */
- /* setSpace() set default disk and user# */
- /* setUp() */
- /* systat() shows current system status */
- /* wildCard() expands ambiguous filenames */
- /* */
- /************************************************************************/
-
- /************************************************************************/
- /* external variable declarations in ROOMA.C */
- /************************************************************************/
- FILE *bannerFile;
- long FDSectCount; /* For accumulating dir. size */
- char debug; /* debug flag */
- char *baseRoom;
- int lastRoom; /* last room visited */
- char remoteSysop = FALSE; /* Is current user a sysop */
- char noBanner;
- int lastPtr;
-
- char *bracket = "]";
- char *arrow = ">";
- char *star = "*";
- char *dotdot = "..";
-
- static int lPtrTab[MAXROOMS]; /* For .Ungoto */
-
- /************************************************************************/
- /* external variable definitions for ROOMA.C */
- /************************************************************************/
- extern struct config cfg; /* A buncha variables */
- extern struct lTable *logTab; /* RAM index of pippuls */
- extern struct logBuffer logBuf; /* Pippul buffer */
- extern FILE *logfl; /* log file descriptor */
- extern FILE *msgfl; /* Message file descriptor */
- extern FILE *msgfl2; /* Another for auto backup */
- extern FILE *netfl; /* Net file */
- extern struct rTable roomTab[MAXROOMS]; /* RAM index of rooms */
- extern struct aRoom roomBuf; /* room buffer */
- extern FILE *roomfl; /* file descriptor for rooms */
- extern int thisRoom; /* room currently in roomBuf */
- extern char loggedIn; /* Are we logged in? */
- extern char expert; /* Are we experienced?? */
- extern char echo; /* output flag */
- extern char prevChar; /* Last char out */
- extern char termLF; /* Need LF's? */
- extern char termUpper; /* Only uppercase? Aw, foo */
- extern char aide; /* aide? */
- extern char sendTime; /* Send time message made? */
- extern char onConsole; /* on console? */
- extern char whichIO; /* where is the I/O? */
- extern unsigned char termNulls; /* How many nulls? */
- extern unsigned char termWidth; /* What's da termwidth? */
- extern int thisSlot; /* Current log slot */
- extern char outFlag;
- extern char nextDay; /* System up before bailout? */
- extern int upDay;
- extern int timeCrash;
- extern char heldMess;
- extern char oldToo;
- extern label oldTarget; /* Room to move messages to */
-
- /************************************************************************/
- /* external function definitions for ROOMA.C */
- /************************************************************************/
- char toUpper();
- FILE *safeopen();
- char *malloc();
- char *formRoom();
-
- /************************************************************************/
- /* dumpRoom() tells us # new messages etc */
- /************************************************************************/
- dumpRoom()
- {
- char hasSkipped;
- label str;
- int fDir();
- int i, count, newCount;
-
- for (newCount = count = i = 0; i < MSGSPERRM; i++) {
- /* Msg is still in system? Count it. */
- if (roomBuf.msg[i].rbmsgNo >= cfg.oldest) {
- count++;
-
- /* don't boggle -- just checking against newest as of */
- /* the last time we were in this room: */
- if (roomBuf.msg[i].rbmsgNo >
- logBuf.lbvisit[ logBuf.lbgen[thisRoom] & CALLMASK ]) {
- newCount++;
- }
- }
- }
- if (!loggedIn && thisRoom == MAILROOM) /* Kludge for new users */
- newCount = count = 1; /* So they see intro. */
-
- mPrintf(" %d messages\n ", count);
- if ((thisRoom == MAILROOM || loggedIn) && newCount > 0)
- mPrintf(" %d new\n", newCount);
-
- if (thisRoom == LOBBY) {
- for (i = LOBBY, hasSkipped = FALSE; i < MAXROOMS; i++)
- if (roomTab[i].rtflags.INUSE == 1 &&
- roomTab[i].rtgen == (logBuf.lbgen[i] >> GENSHIFT)) {
- if (roomTab[i].rtflags.SKIP == 1)
- hasSkipped = TRUE;
- else
- if (roomTab[i].rtlastMessage > (
- logBuf.lbvisit[logBuf.lbgen[i] & CALLMASK] + 1))
- break;
- }
-
- if (i == MAXROOMS && hasSkipped) {
- mPrintf("\n Skipped rooms: \n ");
- for (i = LOBBY; i < MAXROOMS; i++) /* No need to match gen #s. */
- if (roomTab[i].rtflags.SKIP == 1 &&
- roomTab[i].rtflags.INUSE == 1) {
- roomTab[i].rtflags.SKIP = 0; /* Clear. */
- mPrintf(" %s ", formRoom(i, TRUE));
- }
- }
- }
- }
-
- /************************************************************************/
- /* fDir() prints out one filename and size, for a dir listing */
- /************************************************************************/
- fDir(fileName)
- char *fileName;
- {
- FILE *temp;
- long fseek(), size, Sectors;
-
- outFlag = OUTOK;
- if ((temp = safeopen(fileName, "rb")) == NULL)
- return mPrintf("\n ?Can't find file size for %s!", fileName);
-
- size = (fseek(temp, -1l, 2)+1);
- Sectors = ((size + 127) / SECTSIZE);
- FDSectCount += Sectors;
-
- mPrintf("%-15s%5ld%2c", fileName, Sectors, ' ');
- mAbort(); /* chance to next(!)/pause/skip */
- fclose(temp);
- }
-
- /************************************************************************/
- /* fillMailRoom() */
- /************************************************************************/
- fillMailRoom()
- {
- int i;
-
- /* mail room -- copy messages in logBuf to room: */
- for (i = 0; i < MSGSPERRM; i++) {
- roomBuf.msg[i].rbmsgNo = 0l; /* Marks "no" msg */
- roomBuf.msg[i].rbmsgLoc = 0 ; /* Jest fer fun */
- }
- for (i = 0; i < MAILSLOTS; i++) {
- if (i == MSGSPERRM) break; /* for MSGSPRRM < MAILSLOTS */
- roomBuf.msg[i].rbmsgLoc = logBuf.lbslot[i];
- roomBuf.msg[i].rbmsgNo = logBuf.lbId[i] ;
- }
- noteRoom();
- }
-
- /************************************************************************/
- /* gotoRoom() is the menu fn to travel to a new room */
- /* returns TRUE if room is Lobby>, else FALSE */
- /************************************************************************/
- gotoRoom(nam, mode)
- char *nam, mode;
- {
- int i, foundit, roomNo;
- int lPtr, lRoom;
- int roomExists(), partialExist();
-
- lRoom = thisRoom;
- lPtr = (logBuf.lbgen[thisRoom] & CALLMASK);
-
- if (strLen(nam) == 0) {
-
- foundit = FALSE; /* leaves us in Lobby> if nothing found */
- if (mode != 'S') {
- if (loggedIn)
- logBuf.lbgen[thisRoom] = roomBuf.rbgen << GENSHIFT;
- roomTab[thisRoom].rtflags.SKIP = 0;
- }
-
- for (i = 0; i<MAXROOMS && !foundit; i++) {
- if (
- roomTab[i].rtflags.INUSE == 1
- &&
- (roomTab[i].rtgen == (logBuf.lbgen[i] >> GENSHIFT) || aide)
- &&
- roomTab[i].rtflags.SKIP == 0
- ) {
- if (roomTab[i].rtlastMessage >
- logBuf.lbvisit[logBuf.lbgen[i] & CALLMASK] &&
- roomTab[i].rtlastMessage >= cfg.oldest) {
-
- if (i != thisRoom && (i != AIDEROOM || aide)) {
- foundit = i;
- }
- }
- }
- }
-
- lastRoom = lRoom;
- lastPtr = lPtr;
- getRoom(foundit);
- mPrintf("%s\n ", roomBuf.rbname);
- } else {
- foundit = 0;
- /* non-empty room name, so now we look for it: */
- if (
- (roomNo = roomCheck(roomExists, nam)) == ERROR &&
- (roomNo = roomCheck(partialExist, nam)) == ERROR
- ) {
- mPrintf(" ?no %s room\n", nam);
- } else {
- foundit = roomNo;
- if (mode != 'S') {
- if (loggedIn)
- logBuf.lbgen[thisRoom] = roomBuf.rbgen << GENSHIFT;
- roomTab[thisRoom].rtflags.SKIP = 0;
- }
- lastRoom = lRoom; /* For Ungoto */
- lastPtr = lPtr;
- getRoom(roomNo);
-
- /* if may have been unknown... if so, note it: */
- if ((logBuf.lbgen[thisRoom] >> GENSHIFT) != roomBuf.rbgen) {
- logBuf.lbgen[thisRoom] = (
- (roomBuf.rbgen << GENSHIFT) +
- (MAXVISIT -1)
- );
- }
- }
- }
-
- setUp(FALSE);
- dumpRoom();
- return foundit;
- }
-
- /************************************************************************/
- /* initCitadel() does not reformat data files */
- /************************************************************************/
- initCitadel()
- {
- char *msgFile;
- char *msg2File;
- char *roomFile;
- char *logFile;
- char *netFile;
- char *mon;
- int yr, hr, mn;
-
- if (!readSysTab(TRUE))
- exit(CRASH_EXIT);/* No system table? Tacky, tacky*/
- cfg.weAre = CITADEL;
- setSpace(cfg.homeDisk, "");
-
- strCpy(oldTarget, "Aide");
-
- baseRoom = &cfg.codeBuf[cfg.bRoom];
-
- setUp(TRUE);
-
- /* we initmodem at beginning & end both...*/
- modemInit();
- getDate(&yr, &mon, &upDay, &hr, &mn);
- timeCrash = hr + cfg.hourOut;
- if ((nextDay = (timeCrash > 23))) timeCrash %= 24;
-
- #ifndef MSDOS
- if (!cfg.clock) interpret(cfg.pInitDate);
- #endif
-
- /* open message files: */
- msgFile = "a:ctdlmsg.sys";
- msg2File = "a:ctdlmsg.sys";
- logFile = "a:ctdllog.sys";
- roomFile = "a:ctdlroom.sys";
- netFile = "a:ctdlnet.sys";
- *msgFile += cfg.msgDisk;
- *roomFile += cfg.sysDisk;
- *logFile += cfg.sysDisk;
- *netFile += cfg.netDisk;
- if (cfg.mirror) {
- *msg2File += cfg.mbkpDisk;
- openFile(msg2File, &msgfl2);
- }
- openFile(msgFile, &msgfl );
- openFile(roomFile, &roomfl);
- openFile(logFile, &logfl );
- openFile(netFile, &netfl );
-
- noBanner = ((bannerFile = safeopen("banner.blb", "r")) == NULL);
-
- initArchiveList();
- #ifdef MSDOS
- initBadList(); /* MS-DOS only */
- #endif
-
- getRoom(LOBBY); /* load Lobby> */
- setSharedRooms();
- modemInit();
- whichIO = MODEM;
- setUp(FALSE);
- }
-
- /************************************************************************/
- /* legalMatch() Looks for partial matches, checks legalities */
- /************************************************************************/
- legalMatch(i, target)
- label target;
- int i;
- {
- char Equal, *endbuf, *matchString();
-
- Equal = (roomTab[i].rtgen == (logBuf.lbgen[i] >> GENSHIFT));
- if ((roomTab[i].rtflags.INUSE == 1) && (debug || aide || Equal)) {
- for (endbuf = roomTab[i].rtname; *endbuf; endbuf++);
- return (matchString(roomTab[i].rtname, target, endbuf) != NULL);
- }
- return FALSE;
- }
-
- /************************************************************************/
- /* listRooms() lists known rooms */
- /************************************************************************/
- listRooms(what)
- unsigned int what;
- {
- int difference, diff, i, j;
- char str[NAMESIZE+3];
- char shownHidden, isPublic, showPrivate, msgF, hasUnseenStuff;
- static char *legends[] =
- { "Forgotten public rooms",
- "Rooms with unread messages",
- "No unseen msgs in" } ;
-
- mPrintf("\n %s:\n ", legends[(what & 0x000f)]);
- showPrivate = ((what & 0x00C0) > 4);
- msgF = ((what & 0x0030) > 4);
- diff = (what == FGTRMS) ? FORGET_OFFSET : 0;
-
- shownHidden = FALSE;
- for (i = 0; i < MAXROOMS; i++) {
- if (roomTab[i].rtflags.INUSE) {
- j = roomTab[i].rtgen - (logBuf.lbgen[i] >> GENSHIFT);
- difference = abs(j);
- isPublic = roomTab[i].rtflags.PUBLIC;
- if (difference == diff && (showPrivate || isPublic)) {
- hasUnseenStuff = (roomTab[i].rtlastMessage > cfg.oldest &&
- roomTab[i].rtlastMessage >= (
- logBuf.lbvisit[ logBuf.lbgen[i] & CALLMASK ]+1));
- if (what == FGTRMS ||
- (what == NOROLD && !hasUnseenStuff) ||
- ((what == NORNEW || what == LINNEW) && hasUnseenStuff)) {
- mPrintf(" %s ", formRoom(i, TRUE));
- }
- }
- }
- }
- if (!expert && shownHidden && msgF) mPrintf("\n \n * => hidden room\n ");
- }
-
- /************************************************************************/
- /* knowRoom() check to see if current person knows given room */
- /* Return 0 if not know room, 2 if forgot room, 1 otherwise */
- /************************************************************************/
- knowRoom(i)
- int i;
- {
- int difference;
-
- difference = abs(roomTab[i].rtgen - (logBuf.lbgen[i] >> GENSHIFT));
- return ((difference == 0) ? 1 : ((difference == FORGET_OFFSET) ? 2 : 0));
- }
-
- /************************************************************************/
- /* openFile() opens one of the .sys files. */
- /************************************************************************/
- openFile(filename, fd)
- char *filename;
- FILE **fd;
- {
- /* open message file */
- if ((*fd = safeopen(filename, "rwb")) == NULL) {
- printf("?no %s", filename);
- exit(SYSOP_EXIT);
- }
- }
-
- /************************************************************************/
- /* partialExist() roams the list looking for a partial match */
- /************************************************************************/
- partialExist(target)
- label target;
- {
- int rover;
-
- for (rover = (thisRoom + 1) % MAXROOMS; rover != thisRoom;
- rover = (rover + 1) % MAXROOMS)
- if (legalMatch(rover, target)) return rover;
- return ERROR;
- }
-
- /************************************************************************/
- /* retRoom() Ungoto command */
- /************************************************************************/
- retRoom(roomName)
- char *roomName;
- {
- int slot;
- int roomExists(), partialExist();
-
- if (strLen(roomName) == 0) {
- if (lastRoom == -1) {
- mPrintf("No room to Ungoto to!\n ");
- return;
- }
- getRoom(lastRoom);
- logBuf.lbgen[thisRoom] = (logBuf.lbgen[thisRoom] & (~CALLMASK)) + lastPtr;
- lastRoom = -1;
- }
- else {
- if (
- (slot = roomCheck(roomExists, roomName)) == ERROR &&
- (slot = roomCheck(partialExist, roomName)) == ERROR
- ) {
- mPrintf(" ?no %s room\n", roomName);
- return;
- }
- lastRoom = thisRoom;
- lastPtr = (logBuf.lbgen[thisRoom] & CALLMASK);
- getRoom(slot);
- logBuf.lbgen[thisRoom] = lPtrTab[thisRoom];
- }
- setUp(FALSE);
- dumpRoom();
- }
-
- /************************************************************************/
- /* roomCheck() returns slot# of named room else ERROR */
- /************************************************************************/
- roomCheck(checker, nam)
- int (*checker)();
- char *nam;
- {
- int roomNo;
-
- if (
- (roomNo = (*checker)(nam)) == ERROR
- ||
- (roomNo==AIDEROOM && !aide)
- ||
- (roomTab[roomNo].rtflags.PUBLIC == 0 && !loggedIn)
- )
- return ERROR;
- return roomNo;
- }
-
- /************************************************************************/
- /* roomExists() returns slot# of named room else ERROR */
- /************************************************************************/
- int roomExists(room)
- char *room;
- {
- int i;
-
- for (i = 0; i < MAXROOMS; i++) {
- if (
- roomTab[i].rtflags.INUSE == 1 &&
- strCmpU(room, roomTab[i].rtname) == SAMESTRING
- ) {
- return(i);
- }
- }
- return(ERROR);
- }
-
- /************************************************************************/
- /* searchRooms() searches for user string in list of rooms */
- /************************************************************************/
- searchRooms()
- {
- label target;
- char str[NAMESIZE+5];
- int i;
-
- getNormStr("", target, NAMESIZE, ECHO);
-
- mPrintf("Matching rooms:\n ");
- outFlag = OUTOK;
-
- for (i = 0; i < MAXROOMS; i++) {
- if (legalMatch(i, target)) {
- mPrintf(" %s ", formRoom(i, TRUE));
- }
- }
- }
-
- /************************************************************************/
- /* setSpace() moves us to a disk and directory */
- /************************************************************************/
- #define SETDISK 14
- setSpace(disk, dir)
- char disk;
- char *dir;
- {
- bdos(SETDISK, disk);
- cfg.ourDisk = disk;
-
- if (strCmp(dir, "") == SAMESTRING) {
- strCpy(cfg.ourUser, dotdot);
- }
- else {
- strCpy(cfg.ourUser, dir);
- if (chdir(dir) == EOF) {
- mPrintf("?Directory not present!\n ");
- setSpace(cfg.homeDisk, "");
- return FALSE;
- }
- }
- return TRUE;
- }
-
- /************************************************************************/
- /* setUp() */
- /************************************************************************/
- setUp(justIn)
- char justIn;
- {
- int g, i, j, ourSlot;
-
- echo = BOTH; /* just in case */
-
- if (!loggedIn) {
- remoteSysop = FALSE;
- prevChar = ' ';
- termWidth = 32;
- termLF = TRUE;
- termUpper = FALSE;
- termNulls = 5;
- expert = FALSE;
- aide = FALSE;
- sendTime = TRUE;
- oldToo = FALSE;
-
- if (justIn) {
- /* set up logBuf so everything is new... */
- lastRoom = -1;
- heldMess = FALSE;
- for (i = 0; i < MAXVISIT; i++) logBuf.lbvisit[i] = cfg.oldest;
-
- /* no mail for anonymous folks: */
- roomTab[MAILROOM].rtlastMessage = cfg.newest;
- for (i = 0; i < MAILSLOTS; i++) logBuf.lbId[i] = 0l;
-
- logBuf.lbname[0] = 0;
-
- for (i = 0; i < MAXROOMS; i++) {
- if (roomTab[i].rbflags.PUBLIC == 1) {
- /* make public rooms known: */
- g = roomTab[i].rtgen;
- logBuf.lbgen[i] = (g << GENSHIFT) + (MAXVISIT-1);
- } else {
- /* make private rooms unknown: */
- g = (roomTab[i].rtgen + (MAXGEN-1)) % MAXGEN;
- logBuf.lbgen[i] = (g << GENSHIFT) + (MAXVISIT-1);
- }
- lPtrTab[i] = logBuf.lbgen[i];
- }
- }
- } else {
- /* loggedIn: */
- termWidth = logBuf.lbwidth;
- termNulls = logBuf.lbnulls;
- termLF = (logBuf.lbflags.LFMASK == 1) ? TRUE : FALSE ;
- termUpper = (logBuf.lbflags.UCMASK == 1) ? TRUE : FALSE ;
- expert = (logBuf.lbflags.EXPERT == 1) ? TRUE : FALSE ;
- aide = (logBuf.lbflags.AIDE == 1) ? TRUE : FALSE ;
- sendTime = (logBuf.lbflags.TIME == 1) ? TRUE : FALSE ;
- oldToo = (logBuf.lbflags.OLDTOO == 1) ? TRUE : FALSE ;
-
- if (justIn) {
- remoteSysop = FALSE;
- lastRoom = -1;
- heldMess = FALSE;
- /* set gen on all unknown rooms -- INUSE or no: */
- for (i = 0; i < MAXROOMS; i++) {
- if (roomTab[i].rtflags.PUBLIC == 0) {
- /* it is private -- is it unknown? */
- if (((logBuf.lbgen[i] >> GENSHIFT) != roomTab[i].rtgen) ||
- (!aide && i == AIDEROOM)
- ) {
- /* yes -- set gen = (realgen-1) % MAXGEN */
- j = (roomTab[i].rtgen + (MAXGEN-1)) % MAXGEN;
- logBuf.lbgen[ i ] = (j << GENSHIFT) + (MAXVISIT-1);
- }
- }
- else if ((logBuf.lbgen[i] >> GENSHIFT) != roomTab[i].rtgen) {
- /* newly created public room -- remember to visit it; */
- j = roomTab[i].rtgen - (logBuf.lbgen[i] >> GENSHIFT);
- if (j < 0)
- g = -j;
- else
- g = j;
- if (g != FORGET_OFFSET) {
- logBuf.lbgen[i] = (roomTab[i].rtgen << GENSHIFT) +1;
- }
- }
- }
- /* special kludge for Mail> room, to signal new mail: */
- roomTab[MAILROOM].rtlastMessage = logBuf.lbId[MAILSLOTS-1];
-
- /* slide lbvisit array down and change lbgen entries to match: */
- for (i = (MAXVISIT - 2); i; i--) {
- logBuf.lbvisit[i] = logBuf.lbvisit[i-1];
- }
- logBuf.lbvisit[(MAXVISIT - 1)] = cfg.oldest;
- for (i = 0; i < MAXROOMS; i++) {
- if ((logBuf.lbgen[i] & CALLMASK) < (MAXVISIT-2)) {
- logBuf.lbgen[i]++;
- }
- lPtrTab[i] = logBuf.lbgen[i];
- }
-
- /* Slide entry to top of log table: */
- ourSlot = logTab[thisSlot].ltlogSlot;
- slideltab(0, thisSlot);
-
- logTab[0].ltpwhash = hash(logBuf.lbpw);
- logTab[0].ltnmhash = hash(logBuf.lbname);
- logTab[0].ltlogSlot = ourSlot;
- logTab[0].ltnewest = cfg.newest;
- }
- }
- logBuf.lbvisit[0] = cfg.newest;
-
- onConsole = (whichIO == CONSOLE);
- if (thisRoom == MAILROOM) fillMailRoom();
- }
-
- /************************************************************************/
- /* systat() prints out current system status */
- /************************************************************************/
- systat()
- {
- extern char *VERSION;
- int i, year, day, hours, minutes;
- char *month, *m;
- ulong average, work;
- int roomCount;
- unsigned exportSector();
-
- for (roomCount = i = 0; i < MAXROOMS; i++)
- if (roomTab[i].rtflags.INUSE) roomCount++;
-
- getdate(&year, &month, &day, &hours, &minutes);
- if (hours >= 12)
- m = "pm";
- else
- m = "am";
- if (hours >= 13)
- hours -= 12;
- if (hours == 0)
- hours = 12;
-
- mPrintf("This is %s\n ", &cfg.codeBuf[cfg.nodeTitle]);
- mPrintf("%d%s%02d %d:%02d %s (V%s)\n",
- year, month, day, hours, minutes, m, VERSION);
-
- if (loggedIn) {
- mPrintf(" Logged in as %s\n", logBuf.lbname);
- if (logBuf.lbflags.NET_PRIVS)
- mPrintf(" You have net privileges, %d LD credits\n",
- logBuf.credit);
- }
- mPrintf(" %ld messages,", cfg.newest-cfg.oldest +1);
- mPrintf(" last is %lu,\n", cfg.newest );
- mPrintf(" %dK message space,\n", cfg.maxMSector >> 3 );
- mPrintf(" %d-entry log\n", cfg.MAXLOGTAB );
- mPrintf(" %d room slots, %d in use\n", MAXROOMS, roomCount);
- if (cfg.oldest > 1)
- work = cfg.maxMSector;
- else
- work = cfg.catSector;
- work *= 128;
- if (cfg.oldest > 1)
- average = (work) / (cfg.newest - cfg.oldest + 1);
- else
- average = (work) / (cfg.newest);
- mPrintf(" Average message length: %ld\n", average);
- if (cfg.debug) printf("Sector to write to: %u\n", exportSector());
- }
-
- struct dirList {
- char *unambig;
- } ;
-
- /************************************************************************/
- /* wildCard() Do something with the directory */
- /************************************************************************/
- #define UFNsIZE 13 /* size of "filename.ext" plus a null. */
- #define DIR_SIZE 600
-
- wildCard(fn, filename)
- int (*fn)();
- char *filename; /* may be ambiguous. No drive or user numbers. */
- {
- int i, s, sortDir(), fileCount;
- struct dirList *fp, list[DIR_SIZE];
- char *FileList, *ls, *filedir();
-
- if (!setSpace(roomBuf.rbdisk, roomBuf.rbdirname)) return;
-
- /* This is where file names should be made usable */
- if (filename[1] != ':')
- ls = FileList = filedir(filename, 0);
-
- if (filename[1] == ':' || !(*FileList)) {
- /* no such file */
- mPrintf("no %s\n ", filename);
- if (strLen(roomBuf.rbdirname) != 0)
- setSpace(roomBuf.rbdisk, dotdot);
- setSpace(cfg.homeDisk, "");
- if (filename[1] != ':')
- free(ls);
- return;
- }
-
- fp = list;
- fileCount = 0;
-
- while (*FileList) {
- if (fileCount >= DIR_SIZE) {
- mPrintf("too many files!!\n ");
- setSpace(roomBuf.rbdisk, dotdot);
- setSpace(cfg.homeDisk, "");
- return;
- }
- fp->unambig = FileList;
- while (*FileList) FileList++;
- FileList++;
- fp++;
- fileCount++;
- }
-
- qSort(list, fileCount, sizeof list[0], sortDir);
- outFlag = OUTOK;
- for (fp = list; fileCount-- && outFlag != OUTSKIP; fp++)
- (*fn)(fp->unambig);
- if (strLen(roomBuf.rbdirname) != 0)
- setSpace(roomBuf.rbdisk, dotdot);
- setSpace(cfg.homeDisk, "");
- free(ls);
- }
-
- sortDir(s1, s2)
- struct dirList *s1, *s2;
- {
- return strCmp(s1->unambig, s2->unambig);
- }
-